package main

import (
	"fmt"
	"reflect"
)

type User struct {
	Id   int
	Name string
	Age  int
}

func (u User) Call() {
	fmt.Println(u)
}

func (u *User) Call1() {
	fmt.Println(u)
}

func main13() {
	user := User{1, "zhangsan", 30}

	inputType := reflect.TypeOf(user)
	inputValue := reflect.ValueOf(user)

	// 获取属性类型 & 值
	for i := 0; i < inputType.NumField(); i++ {
		field := inputType.Field(i)
		value := inputValue.Field(i).Interface()
		fmt.Println(field, value)
	}

	// 获取方法
	// 注意  *User Call1 没法识别到
	for i := 0; i < inputType.NumMethod(); i++ {
		method := inputType.Method(i)
		fmt.Println(method.Name, method.Type)
	}
}
